package com.wie.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gwb.util.Message;
import com.gwb.util.MoonshotAiUtils;
import com.gwb.util.RoleEnum;
import com.wie.domain.dto.AnalysisResultDTO;
import com.wie.domain.entity.AnalysisResult;
import com.wie.domain.vo.AnalysisResultVO;
import com.wie.service.AnalysisResultService;
import com.wie.mapper.AnalysisResultMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author WiedersehenM
* @description 针对表【analysis_result(数据分析结果)】的数据库操作Service实现
* @createDate 2024-10-21 22:41:33
*/
@Service
public class AnalysisResultServiceImpl extends ServiceImpl<AnalysisResultMapper, AnalysisResult>
    implements AnalysisResultService{

    /**
     * 分析数据
     * @param analysisResultDTO
     * @return
     */
    public String analyzeData(AnalysisResultDTO analysisResultDTO) {
        // 获取数据
        String location = analysisResultDTO.getLocation();
        String beginYear = analysisResultDTO.getBeginYear();
        String endYear = analysisResultDTO.getEndYear();
        // 构建语句
        String message = "请分析" + location + "从" + beginYear + "年到" + endYear + "之间的gdp数据" + ", 并分析经济增长的原因、政策、以及未来趋势";
        List<Message> messages = CollUtil.newArrayList(
                new Message(RoleEnum.system.name(), message)
        );
        MoonshotAiUtils moonshotAiUtils = new MoonshotAiUtils();
        String result = moonshotAiUtils.doChat("moonshot-v1-8k", messages);
        return result;
    }
}




